
using System;
using System.Collections;
using System.Web.UI.WebControls;

namespace GiftNet.Model
{
	#region GainProduct Model -(by fangyifeng at 2007-09-14 12:24:07)

	/// <summary>
	/// GainProduct object'GainProduct'.
	/// </summary>
	[Serializable]
	public class GainProduct : System.IComparable
		{
		#region Member Variables
		
		protected Guid _id;
		protected bool _isGain;
		protected Customer _customer;
		protected Product _product;
		protected DrawAward _draw;
		
		protected static String _sortExpression = "Id";
		protected static SortDirection _sortDirection = SortDirection.Ascending;

		#endregion

		#region Constructors

		public GainProduct() { }

		public GainProduct( bool isGain, Customer customer, Product product, DrawAward draw )
		{
			this._isGain = isGain;
			this._customer = customer;
			this._product = product;
			this._draw = draw;
		}

		#endregion

		#region Public Properties

		public virtual Guid Id
		{
			get {return _id;}
			set {_id = value;}
		}

		public virtual bool IsGain
		{
			get { return _isGain; }
			set { _isGain = value; }
		}

		public virtual Customer Customer
		{
			get { return _customer; }
			set { _customer = value; }
		}

		
		public virtual Product Product
		{
			get { return _product; }
			set { _product = value; }
		}

		
		public virtual DrawAward Draw
		{
			get { return _draw; }
			set { _draw = value; }
		}

		
        public static String SortExpression
        {
            get { return _sortExpression; }
            set { _sortExpression = value; }
        }

        public static SortDirection SortDirection
        {
            get { return _sortDirection; }
            set { _sortDirection = value; }
        }
		#endregion
		
        #region IComparable Methods
        public virtual int CompareTo(object obj)
        {
			if (!(obj is GainProduct))
				throw new InvalidCastException("This object is not of type GainProduct");
			
			int relativeValue;
			switch (SortExpression)
			{
				case "Id":
					relativeValue = this.Id.CompareTo(((GainProduct)obj).Id);
					break;
				case "IsGain":
					relativeValue = this.IsGain.CompareTo(((GainProduct)obj).IsGain);
					break;
                default:
                    goto case "Id";
			}
            if (GainProduct.SortDirection == SortDirection.Ascending)
				relativeValue *= -1;
			return relativeValue;
		}
		#endregion
	}

	#endregion
}
